package com.mrzhou.log;

import org.graylog2.syslog4j.*;

import java.io.UnsupportedEncodingException;

public class SysLogClientMain {

    public static void main(String[] args) throws UnsupportedEncodingException {
        SyslogIF clientInstance= Syslog.getInstance(SyslogConstants.UDP);
        SyslogConfigIF clientConfig = clientInstance.getConfig();
        clientConfig.setHost("10.1.122.111");
        clientConfig.setPort(514);
        // 是否携带主机名称， 关闭不携带
        clientConfig.setSendLocalName(false);
        SyslogMessageIF message = new SyslogMessageIF() {
            @Override
            public String createMessage() {
                return "JSON.toJSONString(jsonObject)";
            }
        };
        clientInstance.notice(message);
    }

}
